package com.xiaoKe.zhonghzu.ui.login;

import android.content.Intent;
import android.os.CountDownTimer;
import android.text.TextUtils;
import android.view.View;

import com.xiaoKe.zhonghzu.MainActivity;
import com.xiaoKe.zhonghzu.R;
import com.xiaoKe.zhonghzu.databinding.ActivityChangepasswordBinding;
import com.xiaoKe.zhonghzu.databinding.ActivityLoginBinding;
import com.xiaoKe.zhonghzu.databinding.ActivityLoginPaswordBinding;
import com.xiaoKe.zhonghzu.global.base.BaseActivity;
import com.xiaoKe.zhonghzu.global.tool.SPUtils;
import com.xiaoKe.zhonghzu.global.tool.ToastUtils;
import com.xiaoKe.zhonghzu.ui.onClick.NoDoubleClickListener;


/**
 * @ProjectName : xiaoke-pad-zhongzhu
 * @Author : Shijingna
 * @Time : 2024/8/5 17:41
 * @Description : 忘记密码
 */
public class ChangePasswordActivity extends BaseActivity<ActivityChangepasswordBinding> {
    CountDownTimer countDownTimer;

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        NoDoubleClickListener noDoubleClickListener = new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View view) {
                switch (view.getId()) {
                    case R.id.code: //获取验证码
                        if (TextUtils.isEmpty(binding.userName.getText().toString())) {
                            ToastUtils.showLong(getString(R.string.用户名不能为空));
                            return;
                        }
                        countDownTimer.start();//验证码倒计时
                        break;
                    case R.id.loginGo: //修改密码去
                        if (TextUtils.isEmpty(binding.userName.getText().toString())) {
                            ToastUtils.showLong(getString(R.string.用户名不能为空));
                            return;
                        } else if (TextUtils.isEmpty(binding.code.getText().toString())) {
                            ToastUtils.showLong("验证码不能为空");
                            return;
                        }
                        startActivity(new Intent(ChangePasswordActivity.this, ChangePasswordActivity2.class).putExtra("titleName","忘记密码"));

                        break;
                    case R.id.goTo: //去密码登录
                        startActivity(new Intent(ChangePasswordActivity.this, LoginActivityPwsWord.class).putExtra("titleName","忘记密码"));
                        finish();
                        break;

                }
            }
        };
        binding.goTo.setOnClickListener(noDoubleClickListener);
        binding.loginGo.setOnClickListener(noDoubleClickListener);
        binding.code.setOnClickListener(noDoubleClickListener);

        countDownTimer = new CountDownTimer(60000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                binding.code.setTextColor(getResources().getColor(R.color.red));
                binding.code.setClickable(false);
                binding.code.setText("(" + millisUntilFinished / 1000 + ") " + getString(R.string.秒后重发));

            }

            @Override
            public void onFinish() {
                binding.code.setText(getString(R.string.重新发送验证码));
                binding.code.setClickable(true);
                binding.code.setTextColor(getResources().getColor(R.color.white));
            }
        };

    }


}
